package com.tianji.learning.mapper;

import com.tianji.api.dto.IdAndNumDTO;
import com.tianji.learning.domain.po.LearningRecord;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 学习记录表 Mapper 接口
 * </p>
 *
 * @author leiyuhang
 * @since 2023-07-24
 */
public interface LearningRecordMapper extends BaseMapper<LearningRecord> {

    @Select("select  lesson_id as id ,count(1) as num from learning_record where user_id=#{userId} " +
            "and finish_time between #{begin} and #{end} and finished = 1  group by lesson_id")
    List<IdAndNumDTO> countLearnedSections(@Param("userId") Long user, @Param("begin") LocalDateTime begin, @Param("end") LocalDateTime end);
}
